# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
#   Mayor.create(:name => 'Daley', :city => cities.first)

Enterprise.create!([
  {
    :name => '海南施洛华',
    :address => '海口华森家具城11号'
  }, {
    :name => '海南星期六',
    :address => '海口华森家具城15号'
  }
])

User.create! [{
  :enterprise_id => Enterprise.first.id,
  :full_name => '陈晓明',
  :mobile => '13976111111',
  :encrypted_password => '1234',
  :email => 'chenxiaoming@gmail.com',
  :status => 'active'
  },{
  :enterprise_id => Enterprise.all[1].id,
  :full_name => '王晓旭',
  :mobile => '13376000000',
  :encrypted_password => '1234',
  :email => 'wangxiaoxu@163.com',
  :status => 'active'
},{
  :enterprise_id => Enterprise.first.id,
  :full_name => '庄必华',
  :mobile => '13976242024',
  :encrypted_password => '1234',
  :email => 'zhbh27@gmail.com',
  :status => 'active'
  }]

Enterprise.first.update_attribute :admin_id, User.first.id
Enterprise.all[1].update_attribute :admin_id, User.all[1].id
# 当前登录企业是 Enterprise.first !!!!!  
Thread.current[:current_user_id] = User.first.id
class Feed < ActiveRecord::Base
  default_scope where :enterprise_id => Enterprise.current_id
end

Order.create! [{
    :enterprise_id => Enterprise.first.id,
    :order_no => '2011041900011',
    :ordered_on => '2011-04-19',
    :buyer_full_name => '庄必华',
    :buyer_phone => '13976242024',
    :buyer_address => '海南省海口市国贸路国贸大厦C座B栋',
    :deliveried_on => '2011-04-24',
    :shop_name => '海口国贸店',
    :saler_full_name => '王明',
    :sale_price => 2000,
    :order_price => 200,
    :after_serviced_cost => 100,
    :status => 'being_edited',
    :remark => '客户不同意有轻微破损的配件,导致多次售后',
    :created_by_user_id => User.first.id,
    :updated_by_user_id =>User.first.id
  },
  {
    :enterprise_id => Enterprise.first.id,
    :order_no => '2011041900121',
    :ordered_on => '2011-04-19',
    :buyer_full_name => '曾小军',
    :buyer_phone => '13973333333',
    :buyer_address => '海南省海口市国贸路国贸大厦A座B栋',
    :deliveried_on => '2011-02-24',
    :shop_name => '海口明珠店',
    :saler_full_name => '王明',
    :sale_price => 3000,
    :order_price => 100,
    :after_serviced_cost => 80,
    :status => 'being_edited',
    :remark => '客户不同意有轻微破损的配件,导致多次售后',
    :created_by_user_id => User.first.id,
    :updated_by_user_id =>User.first.id
  },{
    :enterprise_id => Enterprise.first.id,
    :order_no => '2011041900021',
    :ordered_on => '2011-05-19',
    :buyer_full_name => '张晓明',
    :buyer_phone => '13971111111',
    :buyer_address => '海南省海口市半山花园海天阁1688',
    :deliveried_on => '2011-01-24',
    :shop_name => '解放路店',
    :saler_full_name => '王明',
    :sale_price => 12000,
    :order_price => 2200,
    :after_serviced_cost => 2000,
    :status => 'being_edited',
    :remark => '客户不同意有轻微破损的配件,导致多次售后',
    :created_by_user_id => User.first.id,
    :updated_by_user_id => User.first.id
  }

]

#OrderItem.create!( [{
#    :enterprise_id => Enterprise.first.id,
#    :order_id => Order.first.id,
#    :ordered_count => 3,
#    :furniture_code => 'XXX_FU_1',
#    :furniture_name => '真皮沙发',
#    :furniture_spec => 'XXX_1-红色布',
#    :furniture_color => '蓝色',
#    :remark => '靠枕要田园风格的',
#    :after_serviced_cost => 500,
#    :updated_by_user_id => User.first.id
#  }, {
#    :enterprise_id => Enterprise.first.id,
#    :order_id => Order.first.id,
#    :ordered_count => 5,
#    :furniture_code => 'XXX_CU_1',
#    :furniture_name => '柜子',
#    :furniture_spec => 'XXX_1-橙色布',
#    :furniture_color => '橙色',
#    :remark => '要没有裂痕的',
#    :after_serviced_cost => 300,
#    :updated_by_user_id => User.first.id
#  }
#])
#
#Installation.create!( [ {
#    :enterprise_id => Enterprise.first.id,
#    :installer_full_name => '王昆',
#    :order_item_id => OrderItem.first.id,
#    :has_been_sent_to_installer_count => 3,
#    :installed_count => 2,
#    :after_serviced_count => 0,
#    :after_serviced_cost => 1000,
#    :installed_on => '2011-04-20',
#    :remark => '请尽快安排安装'
#  }, {
#    :enterprise_id => Enterprise.first.id,
#    :installer_full_name => '陈晓',
#    :order_item_id => OrderItem.last.id,
#    :has_been_sent_to_installer_count => 1,
#    :installed_count => 0,
#    :after_serviced_cost => 1200,
#    :after_serviced_count => 1,
#    :installed_on => '2011-04-20',
#    :remark => '还没有安装完成'
#  }
#])

